package com.tsunami.authority.entity.common;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.tsunami.base.entity.SuperEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;

/**
 * <p>
 * 用户登录日志表
 * </p>
 *
 * @author lx
 * @since 2021-09-23
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString(callSuper = true)
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@TableName("tnm_login_log")
@ApiModel(value="LoginLog", description="用户登录日志")
public class LoginLog extends SuperEntity<Long> {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "租户号")
    @TableField(value = "tenant_id")
    private String tenantId;

    @ApiModelProperty(value = "操作IP")
    @TableField(value = "request_ip")
    private String requestIp;

    @ApiModelProperty(value = "登录人ID")
    @TableField(value = "user_id")
    private Long userId;

    @ApiModelProperty(value = "登录人姓名")
    @TableField(value = "user_name")
    private String userName;

    @ApiModelProperty(value = "登录人账号")
    @TableField(value = "account")
    private String account;

    @ApiModelProperty(value = "登录描述")
    @TableField(value = "description")
    private String description;

    @ApiModelProperty(value = "登录时间")
    @TableField(value = "login_time")
    private LocalDateTime loginTime;

    @ApiModelProperty(value = "浏览器请求头")
    @TableField(value = "ua")
    private String ua;

    @ApiModelProperty(value = "浏览器名称")
    @TableField(value = "browser")
    private String browser;

    @ApiModelProperty(value = "浏览器版本")
    @TableField(value = "browser_version")
    private String browserVersion;

    @ApiModelProperty(value = "操作系统")
    @TableField(value = "operating_system")
    private String operatingSystem;

    @ApiModelProperty(value = "登录地点")
    @TableField(value = "location")
    private String location;

    @Builder
    public LoginLog(Long id, LocalDateTime createTime, Long createUser,
                    String requestIp, Long userId, String userName, String account, String description,
                    LocalDateTime loginTime, String ua, String browser, String browserVersion, String operatingSystem, String location) {
        this.id = id;
        this.createTime = createTime;
        this.createUser = createUser;
        this.requestIp = requestIp;
        this.userId = userId;
        this.userName = userName;
        this.account = account;
        this.description = description;
        this.loginTime = loginTime;
        this.ua = ua;
        this.browser = browser;
        this.browserVersion = browserVersion;
        this.operatingSystem = operatingSystem;
        this.location = location;
    }
}
